home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
tex
/
td187src.lzh
/
VECTORFO.I
< prev
next >
Wrap
Text File
|
1991-12-14
|
19KB
|
651 lines
IMPLEMENTATION MODULE VectorFont;
FROM Diverses IMPORT round, NumAlert, Alert, MouseOn, MouseOff;
FROM FileIO IMPORT Fopen, EOF, AgainChar, Reset, Close, ReadChar;
FROM Types IMPORT TextPosTyp, DrawObjectTyp, CodeAryTyp,
ExtendedPtrTyp, ExtendedArraySize,
ObjectPtrTyp;
FROM SYSTEM IMPORT BYTE, WORD, ADDRESS , ADR, TSIZE ;
FROM Storage IMPORT ALLOCATE , DEALLOCATE ;
IMPORT CommonData ;
IMPORT GetFile;
IMPORT MathLib0 ;
IMPORT MagicAES;
IMPORT MagicDOS ;
IMPORT MagicStrings ;
IMPORT MagicSys ;
IMPORT MagicVDI;
IMPORT mtAlerts;
IMPORT mtAppl;
IMPORT Variablen ;
(**
IMPORT Debug;
**)
CONST MaxCache = 1000; (* maximal 1000 Linien puffern *)
DebugMode = FALSE;
LIntMode = FALSE;
TYPE Matrix = ARRAY [1..2],[1..2] OF LONGREAL;
(*$? LIntMode:
IMatrix = ARRAY [1..2],[1..2] OF LONGINT;
*)
ChrString = ARRAY [0..3] OF CHAR;
Buffer = POINTER TO ARRAY [0..32000] OF BYTE;
(* Interne Zeichensatz-Tabelle *)
ChrEntry = RECORD
Header : INTEGER;
Name : INTEGER;
Address : INTEGER;
Width : INTEGER;
Vec : INTEGER;
Bufsize : LONGCARD;
Buf : Buffer;
END;
VAR FontLoaded : INTEGER;
(* Vorbereitung auf mehrere Zeichensätze zur gleichen Zeit *)
ChrTable : ARRAY [1..MaxFonts] OF ChrEntry;
FontSize : LONGCARD;
ActStyle : ChrEntry;
ScaleX, ScaleY : LONGREAL;
Slant : LONGREAL;
Direction : INTEGER;
Turn : Matrix;
(*$? LIntMode:
ITurn : IMatrix;
IScaleX, IScaleY : LONGINT;
ISlant : LONGINT;
*)
CacheIt : BOOLEAN;
CacheFull : BOOLEAN;
Cache : ARRAY [0..4*MaxCache] OF INTEGER;
(* ----------------------------------------------------------------- *)
PROCEDURE EnableCache(enable : BOOLEAN);
BEGIN
CacheIt := enable;
Cache[0] := 0;
END EnableCache;
PROCEDURE AgainText;
VAR dum : INTEGER;
(*$Reg*) i : INTEGER;
(*$Reg*) j : INTEGER;
(*$Reg *) count : INTEGER;
xy : ARRAY [0..3] OF INTEGER;
BEGIN
MagicVDI.SetClipping ( mtAppl.VDIHandle, CommonData.ClipXY , TRUE) ;
MouseOff;
dum := MagicVDI.SetLinecolor ( mtAppl.VDIHandle , MagicAES.BLACK ) ;
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1);
MagicVDI.SetLineEndstyles ( mtAppl.VDIHandle ,
MagicVDI.Cornerd , MagicVDI.Cornerd ) ;
count := 1;
FOR i:=1 TO Cache[0] DO
FOR j:=0 TO 3 DO
xy[j] := Cache[count+j];
END;
MagicVDI.Polyline ( mtAppl.VDIHandle , 2 , xy ) ;
INC(count, 4);
END;
MagicVDI.SetClipping ( mtAppl.VDIHandle , CommonData.ClipXY , FALSE) ;
MouseOn;
END AgainText;
(* ----------------------------------------------------------------- *)
PROCEDURE Integ ( num : BYTE ) : INTEGER;
VAR res : INTEGER;
BEGIN
(**
res := ORD(CHAR(num));
IF res>=80H THEN
res := res - 256;
END;
RETURN res;
**)
RETURN INT(num); (* MM2 spezifisch *)
END Integ;
(* ----------------------------------------------------------------- *)
PROCEDURE SetDirection(angle : INTEGER);
VAR Rangle : LONGREAL; c : CARDINAL;
BEGIN
IF angle<0 THEN
Direction := 360 - (ABS(angle) MOD 360);
ELSE
Direction := angle MOD 360;
END;
(*
Merke: die Drehmatrix bei einer Drehung um α Grad (entgegen dem
Uhrzeigersinn) lautet:
( cos α - cos (90-α) ) ( cos α -sin α )
( ) = ( )
( sin α sin (90-α) ) ( sin α cos α )
*)
(* TDI: Rangle := MathLib0.DegToRad(MathLib0.real(Direction)); *)
Rangle := MathLib0.rad(MathLib0.real(Direction));
Turn [1,1] := MathLib0.cos(Rangle);
Turn [1,2] :=-MathLib0.sin(Rangle);
Turn [2,1] := MathLib0.sin(Rangle);
Turn [2,2] := MathLib0.cos(Rangle);
(*$? LIntMode:
ITurn[1,1] := MathLib0.entier(100.0 * Turn[1, 1]);
ITurn[1,2] := MathLib0.entier(100.0 * Turn[1, 2]);
ITurn[2,1] := MathLib0.entier(100.0 * Turn[2, 1]);
ITurn[2,2] := MathLib0.entier(100.0 * Turn[2, 2]);
*)
END SetDirection;
(* ----------------------------------------------------------------- *)
PROCEDURE TurnedVal( X, Y : INTEGER;
VAR NewX, NewY : INTEGER);
VAR x, y, newx, newy : LONGREAL;
BEGIN
x := MathLib0.real(X) * ScaleX;
y := MathLib0.real(Y) * ScaleY;
x := x + y * Slant;
newx := x * Turn[1,1] + y * Turn[1,2];
newy := x * Turn[2,1] + y * Turn[2,2];
NewX := round(newx);
NewY := round(newy);
END TurnedVal;
(** War ein Versuch der nicht klappte....
PROCEDURE TurnedVal( X, Y : INTEGER;
VAR NewX, NewY : INTEGER);
VAR x, y, newx, newy, it11, it12, it21, it22 : LONGINT;
BEGIN
x := MagicSys.CastToLInt(X);
x := MagicSys.CastToLInt(Y);
(**
x := x + (y * ISlant) DIV 10;
**)
it11 := ITurn[1,1]; it12 := ITurn[1,2];
it21 := ITurn[2,1]; it22 := ITurn[2,2];
(**
newx := x * ITurn[1,1] + y * ITurn[1,2];
newy := x * ITurn[2,1] + y * ITurn[2,2];
**)
newx := (x * it11) + (y * it12);
newy := (x * it21) + (y * it22);
newx := newx * IScaleX;
newy := newy * IScaleY;
NewX := MagicSys.CastToInt(newx DIV 10000);
NewY := MagicSys.CastToInt(newy DIV 10000);
END TurnedVal;
**)
(* ----------------------------------------------------------------- *)
PROCEDURE LoadFont ( REF input : ARRAY OF CHAR;
VAR handle : INTEGER ) : BOOLEAN;
(*
Fragt nach Namen der zu benutzenden Font-Datei
(von Turbo-Pascal/Turbo-C geklaut; die wiederum von Hershey)
*)
VAR ch : CHAR;
i : INTEGER;
filehandle : INTEGER;
length : LONGCARD;
Start : INTEGER;
dummy : INTEGER;
PROCEDURE FontOK(fontname : ARRAY OF CHAR) : BOOLEAN;
(* Überprüft, ob regulärer Font *)
VAR fhandle : INTEGER;
c : CHAR;
res : BOOLEAN;
PROCEDURE CheckChar(char : CHAR);
BEGIN
ReadChar(fhandle, c);
res := res AND (c=char);
END CheckChar;
BEGIN
Reset(fhandle, fontname);
res := TRUE;
CheckChar('P'); (* P hilipp *) (* <- Der Chef von *)
CheckChar('K'); (* K ahn *) (* <- Borland !! *)
Close(fhandle);
RETURN res;
END FontOK;
BEGIN
handle := -1;
IF FontLoaded<MaxFonts THEN
(**
RTD.Message(input);
RTD.ShowVar('FontLoaded', FontLoaded);
**)
IF FontOK(input) THEN
length := GetFile.FileSize(input);
ChrTable[FontLoaded+1].Bufsize := length;
(**
RTD.ShowVar('Size', ChrTable[FontLoaded+1].Bufsize);
**)
IF length>0 THEN
IF Fopen ( filehandle , MagicDOS.Read, input ) THEN
ALLOCATE(ChrTable[FontLoaded+1].Buf, length);
IF ChrTable[FontLoaded+1].Buf <> NIL THEN
WITH ChrTable[FontLoaded+1] DO
MagicDOS.Fread(filehandle, length, Buf);
Close(filehandle);
Start := 3;
(* Anfangs-Message überspringen *)
WHILE (CHAR(Buf^[Start])<>CHAR(1AH)) DO
INC(Start);
END;
Name := Start + 3;
Header := ORD(CHAR(Buf^[Start+1])) +
0100H * ORD(CHAR(Buf^[Start+2]));
Vec := ORD(CHAR(Buf^[Header+5])) +
0100H * ORD(CHAR(Buf^[Header+6]));
Vec := Vec + Header;
Address := Header + 010H;
Width := 2 * ORD(CHAR(Buf^[Header+1]));
Width := Width + Address;
ch := CHAR(Buf^[Header]);
(**
RTD.ShowVar('Name', Name);
R